package list;

public class FanZhuanLianBiao {
    public static void main(String[] args) {
        Node head = new Node(8);
        head.next = new Node(2);
        head.next.next = new Node(3);
        head.next.next.next = new Node(1);
        head.next.next.next.next = new Node(9);

        Node head2 = fanZhuan(head);

        Node n = head2;
        while (n !=null){
            System.out.println(n.value);
            n=n.next;
        }
    }

    private static Node fanZhuan(Node head) {
        Node c = head;
        Node n = null;
        while (c !=null){
            Node t = c.next;
            c.next = n;
            n=c;
            c=t;
        }
        return n;
    }

    static class Node{
        int value;
        Node prev;
        Node next;
        public Node(int value){
            this.value=value;
        }
    }
}
